//package com.xr.common.shiro;
//
//
//import lombok.extern.slf4j.Slf4j;
//import org.apache.shiro.web.filter.AccessControlFilter;
//import org.springframework.http.HttpMethod;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.ServletRequest;
//import javax.servlet.ServletResponse;
//import javax.servlet.http.HttpServletRequest;
//@Component("jwt")
//@Slf4j
//public class TokenFilter extends AccessControlFilter {
//    @Override
//    protected boolean isAccessAllowed(ServletRequest servletRequest, ServletResponse servletResponse, Object o) throws Exception {
//        //检查请求头中是否携带了token
//        HttpServletRequest req = (HttpServletRequest) servletRequest;
//        if (req.getMethod().equals(HttpMethod.OPTIONS.toString())) {
//            return true;
//        }
//        String token = req.getHeader("token");
//        if (token==null){
//            log.info("请求{}没有携带token,请登录",req.getRequestURL());
//            return false;
//        }
//        //检查token是否合法
//        boolean result = checkToken(token);
//        if (result){
//            log.info("请求{}token有效,验证通过",req.getRequestURL());
//            return true;
//        }else {
//            log.info("请求{}token无效",req.getRequestURL());
//            return false;
//        }
//    }
//
//    private boolean checkToken(String token) {
//        return true;
//    }
//
//    @Override
//    protected boolean onAccessDenied(ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
//        return false;
//    }
//}
